package com.wuda.cfg;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * <p>
 * 配置
 * </p>
 * 
 * @author wuda
 * 
 */
public class Configure {

	private Configure() {

	}

	/**
	 * <p>
	 * 词库文件
	 * </p>
	 */
	public static String DIC_RESOURCE = "/com/wuda/dic/words.dic";

	/**
	 * End of sentence punctuation
	 */
	public static String PUNCTION = "。，！？；‘“”：.,!?;'\":　\t\r\n0123456789";

	/**
	 * <p>
	 * 配置文件,在src目录下,目前名称不可修改
	 * </p>
	 */
	public final static String CONF_FILE = "/gt.properties";

	/**
	 * <p>
	 * 加载配置文件,优先使用配置文件中的内容
	 * </p>
	 */
	static {
		InputStream in = Configure.class.getResourceAsStream(CONF_FILE);
		if (in != null) {
			Properties pro = new Properties();
			try {
				pro.load(new InputStreamReader(in, "UTF-8"));
				Object dic_resource = pro.get("dic_resource");
				if (dic_resource != null) {
					DIC_RESOURCE = dic_resource.toString();
				}
				Object punctuation = pro.get("punctuation");
				if (punctuation != null) {
					PUNCTION = punctuation.toString();
				}
			} catch (IOException e) {
				e.printStackTrace();
			} finally {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

}
